GLOBAL['id_check_box_select_all']=false;
function id_check_box_select_all(){
    var alltr=$('listdiv').$$('tr');
    for(var i=0;i<alltr.length;i++){
        var $$$=$$($$(alltr[i],'td')[0],'input')[0];
        if($$$!=undefined){
            $$$.checked=GLOBAL['id_check_box_select_all']?false:true;
        }
    }
    GLOBAL['id_check_box_select_all']=GLOBAL['id_check_box_select_all']?false:true;
}
function id_check_box_swop(){
    var alltr=$('listdiv').$$('tr');
    for(var i=0;i<alltr.length;i++){
        var $$$=$$($$(alltr[i],'td')[0],'input')[0];
        if($$$!=undefined){
            $$$.checked=$$$.checked?false:true;
        }
    }
}
function id_check_box_del(){
    if(_check_select_box()){
        $('brk_form').action=getlocation()+'/collac-manydel';
        $('brk_form').submit();
    }
}
function id_check_box_torecycle(){
    if(_check_select_box()){
        $('brk_form').action=getlocation()+'/collac-manytorecycle';
        $('brk_form').submit();
    }
}
function id_check_box_tolist(){
    if(_check_select_box()){
        $('brk_form').action=getlocation()+'/collac-manytolist';
        $('brk_form').submit();
    }
}


function id_check_box_top(){
    if(_check_select_box()){
        $('brk_form').action=getlocation()+'/collac-com/com-id/fire-top';
        $('brk_form').submit();
    }
}


function id_check_box_sort(){
    $('brk_form').action=getlocation()+'/collac-com/com-id/fire-sort';
    $('brk_form').submit();
}



function _check_select_box(){
    var alltr=$('listdiv').$$('tr');
    var ids=new Array();
    for(var i=0;i<alltr.length;i++){
        var $$$=$$($$(alltr[i],'td')[0],'input')[0];
        if($$$!=undefined){
            if($$$.checked==true){
                ids.push($$$.value)
            }
        }
    }
    if(ids.length==0){
        alert("没有选中项..");
        return false;
    }
    return true;
}

//显示组件选项DIV
GLOBAL['show_Component_Canvas_HTMLS']=new Array();
function show_Component_Canvas_box(id){
    if($(id).innerHTML!=''){
        GLOBAL['show_Component_Canvas_HTMLS'][id]=$(id).innerHTML;
        $(id).innerHTML='';
    }
    $('Component_Canvas_box').style.display="block";
    _set_Component_Canvas_box_innerHTML(GLOBAL['show_Component_Canvas_HTMLS'][id]);
}
//显示组件选项DIV
function _set_Component_Canvas_box_innerHTML($a){
    $('Component_Canvas').innerHTML=$a;
}
//是谁的div被显示了
GLOBAL['show_Component_Canvas_target']=new Array();
function show_Component_Canvas_target(obj){
    obj.style.borderWidth="0px 1px 3px 1px";
    for(var i=0; i<GLOBAL['show_Component_Canvas_target'].length;i++){
        GLOBAL['show_Component_Canvas_target'][i].style.borderBottomWidth="0px 1px 1px 1px";
    }
    GLOBAL['show_Component_Canvas_target'].push(obj);
}
ATTACHMENT_fun_Plugins.push(function(img){
    if(img.attach_type=='.jpg' || img.attach_type=='.png'){
        return "<a href='#' onclick=\"attachment_title_img("+img.attach_id+",'"+img.attach_thumb+"');return false\">标题图片</a>";
    }else{
        return false;
    }
}
)
attachment_title_img=function(attach_id,attach_thumb){
    $('titleimg_element').value=attach_id;
    $('titleimgdiv').innerHTML="<img src='"+attach_thumb+"'/>"
}
ATTACHMENT_fun_Plugins.push(function(img){
    if(img.attach_type=='.jpg' || img.attach_type=='.png' || img.attach_type=='.gif'){
        return "<a href='#' onclick=\"attachment_photo_coll_add("+img.attach_id+",'"+img.attach_thumb+"','',0);return false\">图集</a>";
    }else{
        return false;
    }
}
)
//{"photo_id":"1","photo_coll_id":"6","attach_id":"200","photo_sort":"0","photo_desc":""}
attachment_photo_coll_add_all=function(all){
    if(typeof(all) =='object'){
        for(var i=0;i<all.length;i++){
            var o = all[i];
            attachment_photo_coll_add(o.attach_id,ROOT+o.attach_thumb,o.photo_desc,o.photo_sort);
        }
    }
}

attachment_photo_coll_add=function(attach_id,attach_thumb,$textarea,$sort){
    var inputs=$('photo_coll_hidden_inputs').$$('input');
    for(var i = 0 ; i<inputs.length;i++){
        if(inputs[i].value==attach_id){
            return;
        }
    }
    
    var inputEle=document.createElement('input');
    inputEle.type='hidden';
    inputEle.value=attach_id;
    inputEle.name='Component[photos][attach_id][]';
    $('photo_coll_hidden_inputs').appendChild(inputEle);

    var one=document.createElement('div');
    one.className='photo_coll_one_div';
    one.id='photo_coll_one_div_'+attach_id;
    one.innerHTML=
    "<div class='photo_coll_one_div_left'><img src='"+attach_thumb+"' onload='attachment_photo_align(this)'/></div>"+
    "<div class='photo_coll_one_div_right'>描述:<br/><textarea name='Component[photos][attach_desc]["+attach_id+"]'>"+$textarea+"</textarea><br/>"+
    "排序:<input name='Component[photos][attach_sort]["+attach_id+"]' class='input_text_photo_coll_2' value='"+$sort+"' /><br/>"+
    "<input type='button' value='丢掉图片' onclick='photo_coll_one_delete("+attach_id+")' /></div>";
    $('photo_coll_big_div').appendChild(one);
}

photo_coll_one_delete=function(id){
    try{
        $('photo_coll_big_div').removeChild($('photo_coll_one_div_'+id));
        var inputs=$('photo_coll_hidden_inputs').$$('input');
        for(var i = 0 ; i<inputs.length;i++){
            if(inputs[i].value==id){
                $('photo_coll_hidden_inputs').removeChild(inputs[i]);
                continue;
            }
        }
    }catch(e){}
}

attachment_photo_align=function(img){
    var xyz=_zoom(img.width,img.height,140,140);
    img.width=xyz[0];
    img.height=xyz[1];
    img.style.border="1px solid teal";
    img.style.marginTop=parseInt((150-img.height)/2) + 'px';
}
